package com.efuture.chapterfive

/* @Description: Kotlin语言枚举类定义函数学习
 * @Auther: zhaoshanshan
 * @Date: 2022/03/07/3:16 下午
 */
class LimbsInfo(var limbsInfo:String,var len:Int){//四肢信息class

}
enum class Demo89(var limbsMsg:LimbsInfo){
    //枚举值的定义 必须是所有的枚举值保持一致的效果
    LEFT_HAND(LimbsInfo("左手",80)),
    RIGHT_HAND(LimbsInfo("右手",80)),
    LEFT_FOOT(LimbsInfo("左脚",120)),
    RIGHT_FOOT(LimbsInfo("右脚",120));

    fun show(){
        println("四肢是:${limbsMsg.limbsInfo}的长度是${limbsMsg.len}")
    }
    fun updataData(limbsInfo:LimbsInfo){
        this.limbsMsg.limbsInfo = limbsInfo.limbsInfo;
        this.limbsMsg.len = limbsInfo.len
        println("更新后的数据为:${this.limbsMsg}")
    }

}

fun main() {

    println(Demo89.LEFT_HAND.show())
    println(Demo89.RIGHT_HAND.show())
    println(Demo89.LEFT_FOOT.show())
    println(Demo89.RIGHT_FOOT.show())

    println(Demo89.LEFT_HAND.updataData(LimbsInfo("左手",90)))
    println(Demo89.RIGHT_HAND.updataData(LimbsInfo("右手",90)))
    println(Demo89.LEFT_FOOT.updataData(LimbsInfo("左脚",140)))
    println(Demo89.RIGHT_FOOT.updataData(LimbsInfo("右脚",140)))

}